package tcp

import (
	"io"
	httpProto "tunnel_manager/protocols/http"
)

// HTTP2ClientPoolAdapter 实现handler包中定义的接口
type HTTP2ClientPoolAdapter struct {
	*HTTP2ClientPool
}

// SelectConnection 实现接口方法
func (a *HTTP2ClientPoolAdapter) SelectConnection() httpProto.HTTP2TunnelClient {
	wrapper := a.HTTP2ClientPool.SelectConnection()
	if wrapper == nil {
		return nil
	}
	return wrapper
}

// HasConnectedClient 实现接口方法
func (a *HTTP2ClientPoolAdapter) HasConnectedClient() bool {
	return a.HTTP2ClientPool.HasConnectedClient()
}

// Ensure HTTP2TunnelClientWrapper implements httpProto.HTTP2TunnelClient interface
var _ httpProto.HTTP2TunnelClient = (*HTTP2TunnelClientWrapper)(nil)

// Ensure HTTP2ClientPoolAdapter implements httpProto.HTTP2ClientPool interface
var _ httpProto.HTTP2ClientPool = (*HTTP2ClientPoolAdapter)(nil)

// HTTP2TunnelClientWrapper 包装器，实现接口
type HTTP2TunnelClientWrapper struct {
	*HTTP2TunnelClient
}

func (w *HTTP2TunnelClientWrapper) SendResponseZeroCopy(requestID string, responseReader io.Reader) error {
	return w.HTTP2TunnelClient.SendResponseZeroCopy(requestID, responseReader)
}

func (w *HTTP2TunnelClientWrapper) IsConnected() bool {
	return w.HTTP2TunnelClient.IsConnected()
}

func (w *HTTP2TunnelClientWrapper) GetActiveStreams() int64 {
	return w.HTTP2TunnelClient.GetActiveStreams()
}
